package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.QuartzJob;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class QuartzJobVO {

    private static final long serialVersionUID = 1L;

    private String id;

    @ApiModelProperty(value = "创建人")
    private String createBy;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "删除状态")
    private Integer delFlag;

    @ApiModelProperty(value = "修改人")
    private String updateBy;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "任务类名")
    private String jobClassName;

    @ApiModelProperty(value = "cron表达式")
    private String cronExpression;

    @ApiModelProperty(value = "参数")
    private String parameter;

    @ApiModelProperty(value = "描述")
    private String description;

    @ApiModelProperty(value = "状态0正常-1停止")
    private Integer status;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static QuartzJob convert(QuartzJobVO vo) {
        QuartzJob entity = new QuartzJob();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<QuartzJob> convertList(List<QuartzJobVO> list) {
        List<QuartzJob> resultList = new ArrayList<>();
        for (QuartzJobVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
